/**
 * 模态框
 */
module.exports = function ($scope, $state, $stateParams,$resource,$modal) {
	/* 分页
     * ========================================= */
    $scope.maxSize = 5;             //最多显示多少个按钮
    $scope.currentPage = 1;      //当前页码
    $scope.itemsPerPage = 10         //每页显示几条
	


	$scope.pageChanged = function () {
       var para = {
            pageNo:$scope.currentPage,
            pageSize:$scope.itemsPerPage,

            
        };
		

		$resource('/api/ac/dsc/trafficService/findTaskList', {}, {}).
			save(para, function(res){			
                 
                if(res.errcode === 0 || res.errcode === 10003){
					console.log(res);
					$scope.objs=res.data.results;									
					$scope.totalItems = res.data.totalRecord;


                }else{
                    alert(res.errmsg);
                }
            });


    };
	// $scope.pageChanged();


			$scope.search=function(){
			var dic = {
				pageNo:$scope.currentPage,
            	pageSize:$scope.itemsPerPage,
				
			}
				
				$resource('', {}, {}).save(dic, function(res){
                if(res.errcode === 0 || res.errcode === 10003){
                    // console.log(res);
					$scope.objs=res.data.results;
                    $scope.totalItems = res.data.totalRecord;
                }else{
                    alert(res.errmsg);
                }
            });
			}

			// $scope.apply= function (index) {    
			// 	console.log($scope.objs[index].project_code) ;          
			// 	 if(confirm('是否推荐此项目？')){
			// 		$resource('/api/as/ggc/reviewDistrictTourism/updateByRecommend', {}, {}).save({'project_code':$scope.objs[index].project_code}, function(res){			              
            //     if(res.errcode === 0 || res.errcode === 10003){
			// 			alert('推荐成功')			
			// 			$scope.pageChanged();
            //     }else{
            //         alert(res.errmsg);
            //     }
            // });
				
			// 	 }		
				 
			// }

            $scope.toinfo= function () {
                //  $scope.item = $scope.objs[index];
                // console.log($scope.objs[index]);	
						
				var modalInstance = $modal.open({
					template: require('../views/order_info.html'),
					controller: 'order_info',
					size: 'lg',
					resolve: {
						// items: function () {
						// 	return $scope.item;
						// }
					}
				});
				// modalInstance.result.then(function (showResult) {	
				// 		$scope.pageChanged();
				// });
			}

			$scope.changecar = function(){
				console.log('11111');
				var modalInstance = $modal.open({
					template: require('../views/change_car.html'),
					controller: 'change_car',
					size: 'lg',
					resolve: {
						// items: function () {
						// 	return $scope.item;
						// }
					}
				});
				modalInstance.result.then(function (showResult) {	
						$scope.pageChanged();
				});

			}

}